package com.orange.common.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class DateUtil
{
  public static String CHINA_TIMEZONE;
  public static String DATE_FORMAT = "yyyyMMddHHmmss";

  static
  {
    CHINA_TIMEZONE = "GMT+0800";
  }

  public static int calcHour(Date paramDate1, Date paramDate2)
  {
    int i;
    if (paramDate1.before(paramDate2))
    {
      long l = paramDate1.getTime();
      i = (int)((paramDate2.getTime() - l) / 3600000L);
    }
    while (true)
    {
      return i;
      i = -1;
    }
  }

  public static String currentDate()
  {
    return dateToStringByFormat(new Date(), DATE_FORMAT);
  }

  public static String dateDescription(Date paramDate)
  {
    String str;
    if (paramDate == null)
      str = "(null)";
    while (true)
    {
      return str;
      str = paramDate.toString();
    }
  }

  public static Date dateFromChineseStringByFormat(String paramString1, String paramString2)
  {
    return dateFromStringByFormat(paramString1, paramString2, "GMT+0800");
  }

  public static Date dateFromString(String paramString)
  {
    return dateFromStringByFormat(paramString, DATE_FORMAT);
  }

  public static Date dateFromStringByFormat(String paramString1, String paramString2)
  {
    Object localObject;
    if ((paramString1 == null) || (paramString1.length() == 0) || (paramString2 == null))
    {
      localObject = null;
      return localObject;
    }
    SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat(paramString2);
    localSimpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    try
    {
      Date localDate = localSimpleDateFormat.parse(paramString1);
      localObject = localDate;
    }
    catch (ParseException localParseException)
    {
      localObject = null;
    }
  }

  public static Date dateFromStringByFormat(String paramString1, String paramString2, String paramString3)
  {
    Object localObject;
    if ((paramString1 == null) || (paramString2 == null))
    {
      localObject = null;
      return localObject;
    }
    SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat(paramString2);
    localSimpleDateFormat.setTimeZone(TimeZone.getTimeZone(paramString3));
    try
    {
      Date localDate = localSimpleDateFormat.parse(paramString1);
      localObject = localDate;
    }
    catch (ParseException localParseException)
    {
      localObject = null;
    }
  }

  public static String dateToChineseStringByFormat(Date paramDate, String paramString)
  {
    String str;
    if ((paramDate == null) || (paramString == null))
      str = null;
    while (true)
    {
      return str;
      SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat(paramString);
      TimeZone localTimeZone = TimeZone.getTimeZone("GMT+0800");
      Calendar localCalendar = Calendar.getInstance(localTimeZone, Locale.CHINA);
      localSimpleDateFormat.setTimeZone(localTimeZone);
      localSimpleDateFormat.setCalendar(localCalendar);
      str = localSimpleDateFormat.format(paramDate);
    }
  }

  public static String dateToString(Date paramDate)
  {
    return dateToStringByFormat(paramDate, DATE_FORMAT);
  }

  public static String dateToStringByFormat(Date paramDate, String paramString)
  {
    String str;
    if ((paramDate == null) || (paramString == null))
      str = null;
    while (true)
    {
      return str;
      SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat(paramString);
      localSimpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
      str = localSimpleDateFormat.format(paramDate);
    }
  }

  public static Date getChineseDateOfToday()
  {
    Calendar localCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+0800"));
    localCalendar.setTime(new Date());
    localCalendar.set(11, 0);
    localCalendar.set(12, 0);
    localCalendar.set(13, 0);
    localCalendar.set(14, 0);
    return localCalendar.getTime();
  }

  public static Date getChineseDateOfTodayTime(int paramInt1, int paramInt2, int paramInt3)
  {
    Calendar localCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+0800"));
    localCalendar.setTime(new Date());
    localCalendar.set(11, paramInt1);
    localCalendar.set(12, paramInt2);
    localCalendar.set(13, paramInt3);
    localCalendar.set(14, 0);
    return localCalendar.getTime();
  }

  public static Date getChineseDateOfTomorrowTime(int paramInt1, int paramInt2, int paramInt3)
  {
    Calendar localCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+0800"));
    localCalendar.setTime(new Date());
    localCalendar.add(5, 1);
    localCalendar.set(11, paramInt1);
    localCalendar.set(12, paramInt2);
    localCalendar.set(13, paramInt3);
    localCalendar.set(14, 0);
    return localCalendar.getTime();
  }

  public static long getCurrentTime()
  {
    return new Date().getTime();
  }

  private static Date getGMT8Date()
  {
    Calendar localCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+0800"));
    localCalendar.setTime(new Date());
    return localCalendar.getTime();
  }

  public static boolean isMiddleDate(int paramInt1, int paramInt2, int paramInt3, int paramInt4, String paramString)
  {
    int i;
    TimeZone localTimeZone = TimeZone.getTimeZone(paramString);
    Calendar localCalendar1 = Calendar.getInstance(localTimeZone);
    Calendar localCalendar2 = Calendar.getInstance(localTimeZone);
    localCalendar1.set(11, paramInt1);
    localCalendar1.set(12, paramInt2);
    localCalendar2.set(11, paramInt3);
    localCalendar2.set(12, paramInt4);
    Date localDate1 = localCalendar1.getTime();
    Date localDate2 = localCalendar2.getTime();
    Date localDate3 = new Date();
    if ((localDate3.after(localDate1)) && (localDate3.before(localDate2)))
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }
}